﻿using RXY_Mall.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace RXY_Mall.AdminApi.Models
{

    /// <summary>
    /// 添加订单
    /// </summary>
    public class AddOrderInput : BaseInput
    {
        ///// <summary>
        ///// 拼单ID
        ///// </summary>
        //public int? order_group_id { get; set; }
        ///// <summary>
        ///// 商品SkuID
        ///// </summary>
        //public int sku_id { get; set; }
        ///// <summary>
        ///// 商品数量
        ///// </summary>
        //public int quantity { get; set; }
        /// <summary>
        /// 购物车
        /// </summary>
        public List<int> cart_ids { get; set; }
        /// <summary>
        /// 领取用户优惠券ID
        /// </summary>
        public int? user_coupon_id { get; set; }
        /// <summary>
        /// 购买方式
        /// </summary>
        public BuyType buy_type { get; set; }        
        /// <summary>
        /// 地址ID
        /// </summary>
        public int address_id { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }
        /// <summary>
        /// 支付类型
        /// </summary>
        public PayType pay_type { get; set; }
        /// <summary>
        /// 平台类型
        /// </summary>
        public PlatformType platform_type { get; set; }
    }

    public class AddOrderOutput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 返回的数据
        /// </summary>
        public string data { get; set; }
    }


    /// <summary>
    /// 余额支付订单输入信息
    /// </summary>
    public class PayOrderByBalanceInput : BaseInput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 支付密码
        /// </summary>
        public string pay_password { get; set; }
    }

    /// <summary>
    /// 取消订单输入信息
    /// </summary>
    public class CancelOrderInput : BaseInput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
    }

    public class UpdateAddressInput : BaseInput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 地址ID
        /// </summary>
        public int address_id { get; set; }
    }

    /// <summary>
    /// 评论订单
    /// </summary>
    public class CommentOrderInput : BaseInput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        [Required(ErrorMessage = "订单号不能为空！")]
        public string order_no { get; set; }
        /// <summary>
        /// 商品描述打分
        /// </summary>
        public byte description_mark { get; set; }
        /// <summary>
        /// 商家态度打分
        /// </summary>
        public byte attitude_mark { get; set; }
        /// <summary>
        /// 物流服务打分
        /// </summary>
        public byte logistics_mark { get; set; }
        /// <summary>
        /// 评论
        /// </summary>
        [Required(ErrorMessage = "评论不能为空！")]
        public string comment { get; set; }
        /// <summary>
        /// 评论照片
        /// </summary>
        public List<string> pictures { get; set; }
        /// <summary>
        /// 是否匿名
        /// </summary>
        public bool is_anonymity { get; set; }
        /// <summary>
        /// 选中商品标签
        /// </summary>
        public List<int> tags { get; set; }
    }

    /// <summary>
    /// 余额支付订单输入信息
    /// </summary>
    public class GetPayInfoInput : BaseInput
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
    }

    /// <summary>
    /// 订单列表输出信息
    /// </summary>
    public class GetOrderListOutput
    {
        internal DateTime _add_time;
        internal string json_specs;
        internal gw_order_group gw_order_group;
        
        internal DateTime pay_expire_time;
        //internal int user_num;
        //internal bool is_leader;

        ///// <summary>
        ///// 退换单
        ///// </summary>
        //public ReturnOrder return_order { get; set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public long add_time { get; set; }
        /// <summary>
        /// 采购数量
        /// </summary>
        public int goods_count { get; internal set; }
        /// <summary>
        /// 订单金额
        /// </summary>
        public decimal goods_total { get; internal set; }
        /// <summary>
        /// 支付类型
        /// </summary>
        public PayType pay_type { get; internal set; }
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 订单状态
        /// </summary>
        public OrderStatus order_status { get; set; }
        /// <summary>
        /// 支付状态
        /// </summary>
        public PayStatus pay_status;
        /// <summary>
        /// 运费
        /// </summary>
        public string shipping_fee { get; set; }
        /// <summary>
        /// 优惠
        /// </summary>
        public string discounts { get; set; }
        /// <summary>
        /// 订单实付
        /// </summary>
        public string amount { get; set; }

        ///// <summary>
        ///// 店铺ID
        ///// </summary>
        //public int shop_id { get; set; }
        ///// <summary>
        ///// 店铺名称
        ///// </summary>
        //public string shop_name { get; set; }
        ///// <summary>
        ///// 店铺logo
        ///// </summary>
        //public string shop_logo { get; set; }

        ///// <summary>
        ///// 商品ID
        ///// </summary>
        //public int goods_id { get; set; }
        ///// <summary>
        ///// 商品类型
        ///// </summary>
        //public GoodsType goods_type { get; set; }
        ///// <summary>
        ///// 商品名
        ///// </summary>
        //public string goods_name { get; set; }
        ///// <summary>
        ///// 商品图片
        ///// </summary>
        //public string picture_url { get; set; }
        ///// <summary>
        ///// 商品价格
        ///// </summary>
        //public string goods_price { get; set; }
        ///// <summary>
        ///// 商品数量
        ///// </summary>
        //public int goods_quantity { get; set; }
        ///// <summary>
        ///// 商品规格
        ///// </summary>
        //public List<SpecOutput> specs { get; set; }        
        ///// <summary>
        ///// 购买类型
        ///// </summary>
        //public BuyType buy_type { get; internal set; }
        ///// <summary>
        ///// 拼单需要人数
        ///// </summary>
        //public int require_num { get; set; }
        ///// <summary>
        ///// 拼单人数
        ///// </summary>
        //public int user_num { get; internal set; }

        ///// <summary>
        ///// 拼单
        ///// </summary>
        //public OrderGroupOutput group { get; internal set; }
        ///// <summary>
        ///// 售后状态
        ///// </summary>
        //public byte? service_status { get; set; }
        ///// <summary>
        ///// 售后过期时间
        ///// </summary>
        //public DateTime? service_expire_time { get; set; }
    }

    /// <summary>
    /// 订单详情输出信息
    /// </summary>
    public class GetOrderOutput
    {
        
        //internal gw_order_group gw_order_group;
        //internal bool is_leader;
        internal gw_order_waybill gw_order_waybill;

        internal DateTime _add_time;
        //internal DateTime? _group_time;
        internal DateTime? _pay_time;
        internal DateTime? _receive_time;
        internal DateTime? _shipment_time;
        internal DateTime? _cancel_time;
        internal DateTime? _complete_time;
        //internal DateTime? _comment_time;
        internal DateTime pay_expire_time;

        ///// <summary>
        ///// 退换货单
        ///// </summary>
        //public ReturnOrder return_order { get; set; }
        ///// <summary>
        ///// 售后状态
        ///// </summary>
        //public byte? service_status { get; set; }
        ///// <summary>
        ///// 售后过期时间
        ///// </summary>
        //public DateTime? service_expire_time { get; set; }

        //internal DateTime _pay_time;
        //internal DateTime _group_time;
        //internal DateTime _shipment_time;
        //internal DateTime _receive_time;
        /// <summary>
        /// 订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 订单状态
        /// </summary>
        public OrderStatus order_status { get; set; }
        /// <summary>
        /// 运费
        /// </summary>
        public string shipping_fee { get; set; }
        /// <summary>
        /// 优惠
        /// </summary>
        public string discounts { get; set; }
        /// <summary>
        /// 订单实付
        /// </summary>
        public string amount { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public long add_time { get; set; }
        /// <summary>
        /// 支付时间
        /// </summary>
        public long pay_time { get; set; }
        ///// <summary>
        ///// 拼单时间
        ///// </summary>
        //public long group_time { get; set; }
        /// <summary>
        ///  发货时间
        /// </summary>
        public long shipment_time { get; set; }
        /// <summary>
        /// 收货时间
        /// </summary>
        public long receive_time { get; set; }
        /// <summary>
        /// 取消时间
        /// </summary>
        public long cancel_time { get; internal set; }
        /// <summary>
        /// 完成时间
        /// </summary>
        public long complete_time { get; internal set; }
        ///// <summary>
        ///// 评论时间
        ///// </summary>
        //public long comment_time { get; internal set; }        
        /// <summary>
        /// 支付类型
        /// </summary>
        public PayType pay_type { get; set; }
        /// <summary>
        /// 订单地址
        /// </summary>
        public OrderAddress address { get; set; }
        /// <summary>
        /// 订单商品
        /// </summary>
        public List<OrderGoods> goods { get; set; }
        /// <summary>
        /// 运单信息
        /// </summary>
        public Waybill waybill { get; set; }
        ///// <summary>
        ///// 拼单
        ///// </summary>
        //public OrderGroupOutput group { get; internal set; }
        ///// <summary>
        ///// 店铺
        ///// </summary>
        //public ShopOutput shop { get; internal set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }
    }

    /// <summary>
    /// 订单信息输出信息
    /// </summary>
    public class GetOrderCountOutput
    {
        /// <summary>
        /// 待付款数量
        /// </summary>
        public int PayCount { get; set; }
        /// <summary>
        /// 待分享数量
        /// </summary>
        public int GroupCount { get; set; }
        /// <summary>
        /// 待发货数量
        /// </summary>
        public int ShipmentCount { get; set; }
        /// <summary>
        /// 待收货数量
        /// </summary>
        public int ReceiveCount { get; set; }
        /// <summary>
        /// 待评论数量
        /// </summary>
        public int CommentCount { get; set; }
        /// <summary>
        /// 拼单失败
        /// </summary>
        public int FailureCount { get; internal set; }
        /// <summary>
        /// 订单完成数量
        /// </summary>
        public int CompleteCount { get; internal set; }
        /// <summary>
        /// 订单取消
        /// </summary>
        public int CancelCount { get; internal set; }
        /// <summary>
        /// 退换数量
        /// </summary>
        public int ReturnCount { get; set; }
    }

    public class ReturnOrder
    {
        /// <summary>
        /// 退单号
        /// </summary>
        public string return_no { get; set; }
        /// <summary>
        /// 是否可申请售后
        /// </summary>
        public bool is_return_request { get; set; }
    }

    /// <summary>
    /// 拼单订单
    /// </summary>
    public class OrderGroupOutput
    {
        /// <summary>
        /// 拼单类型
        /// </summary>
        public GroupType group_type { get; set; }
        /// <summary>
        /// 拼单ID
        /// </summary>
        public int order_group_id { get; set; }
        /// <summary>
        /// 拼单号
        /// </summary>
        public string order_group_no { get; set; }
        /// <summary>
        /// 需要人数
        /// </summary>
        public int require_num { get; set; }
        /// <summary>
        /// 至少瓜分红包
        /// </summary>
        public float red_packet { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public long add_time { get; set; }
        /// <summary>
        /// 过期时间
        /// </summary>
        public long expire_time { get; set; }
        /// <summary>
        /// 取消时间
        /// </summary>
        public long cancel_time { get; set; }
        /// <summary>
        /// 完成时间
        /// </summary>
        public long complete_time { get; set; }
        /// <summary>
        /// 拼单状态
        /// </summary>
        public GroupStatus group_status { get; set; }
        /// <summary>
        /// 是否发红包
        /// </summary>
        public bool is_red_packet { get; set; }
        /// <summary>
        /// 是否是发起人
        /// </summary>
        public bool is_leader { get; internal set; }
        /// <summary>
        /// 拼单用户
        /// </summary>
        public List<GroupUser> group_users { get; set; }
        /// <summary>
        /// 红包
        /// </summary>
        public GetRedpacketOutput redpacket { get; set; }


    }

    public class GroupUser
    {
        internal string mobile;
        internal int? order_id;

        /// <summary>
        /// 昵称
        /// </summary>
        public string nick_name { get; set; }
        /// <summary>
        /// 用户图标
        /// </summary>
		public string logo { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public int user_id { get; set; }
        /// <summary>
        /// 是否是拼主
        /// </summary>
        public bool is_leader { get; set; }
        /// <summary>
        /// 是否获奖
        /// </summary>
        public bool? is_award { get; set; }
        /// <summary>
        /// 获得红包
        /// </summary>
        public decimal? acquire_red_packet { get; set; }
        /// <summary>
        /// 获得时间
        /// </summary>
        public long acquire_time { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public long add_time { get; set; }
        /// <summary>
        /// 合体状态 1-合体中 2-合体成功 4-合体失败
        /// </summary>
        public byte? help_state { get; internal set; }
        /// <summary>
        /// 合体成功时间
        /// </summary>
        public DateTime? complete_time { get; internal set; }
    }

    /// <summary>
    /// 运单信息
    /// </summary>
    public class Waybill
    {
        /// <summary>
        /// 运单号
        /// </summary>
        public string waybill_no { get; set; }
        /// <summary>
        /// 物流公司
        /// </summary>
        public string company_name { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        public string telphone { get; set; }
    }

    /// <summary>
    /// 订单商品
    /// </summary>
    public class OrderGoods
    {
        internal string json_specs;        
        /// <summary>
        /// 商品类别ID
        /// </summary>
        public int category_id { get; set; }
        /// <summary>
        /// 商品ID
        /// </summary>
        public int goods_id { get; set; }
        /// <summary>
        /// 商品类型
        /// </summary>
        public GoodsType goods_type { get; set; }
        /// <summary>
        /// 商品名
        /// </summary>
        public string goods_name { get; set; }
        /// <summary>
        /// 购买类型
        /// </summary>
        public BuyType buy_type { get; set; }
        /// <summary>
        /// 商品规格
        /// </summary>
        public List<SpecOutput> specs { get; set; }
        /// <summary>
        /// 商品价格
        /// </summary>
        public string goods_price { get; set; }
        /// <summary>
        /// 商品数量
        /// </summary>
        public int goods_quantity { get; set; }
        /// <summary>
        /// 商品图片
        /// </summary>
        public string picture_url { get; set; }
        /// <summary>
        /// 商品图片
        /// </summary>
        public string summary { get; set; }
    }

    /// <summary>
    /// 订单地址
    /// </summary>
    public class OrderAddress
    {
        /// <summary>
        /// 收货人
        /// </summary>
        public string accepter_name { get; set; }
        /// <summary>
        /// 电话号码
        /// </summary>
        public string mobile { get; set; }
        /// <summary>
        /// 省市区逗号分隔
        /// </summary>
        public string area { get; set; }
        /// <summary>
        /// 详细地址
        /// </summary>
        public string address { get; set; }
    }

    /// <summary>
    /// 添加会员订单输入信息
    /// </summary>
    public class AddMemberOrderInput : BaseInput
    {
        ///// <summary>
        ///// 购买方式 1-付费购买
        ///// </summary>
        //public int buy_type { get; set; }
        ///// <summary>
        ///// 购买年限 1-1年
        ///// </summary>
        //public int buy_year { get; set; }
        /// <summary>
        /// 支付方式
        /// </summary>
        public PayType pay_type { get; set; }
        ///// <summary>
        ///// 应付金额
        ///// </summary>
        //public decimal pay_money { get; set; }
    }

    /// <summary>
    /// 运单详情
    /// </summary>
    public class WaybillDetail
    {
        public DateTime time { get; set; }
        public string context { get; set; }
        public DateTime ftime { get; set; }

    }

    public class WaybillInfo
    {
        public string message { get; set; }
        public string nu { get; set; }
        public int ischeck{ get; set; }
        public string com{ get; set; }
        public string status{ get; set; }
        public string condition{ get; set; }
        public int state{ get; set; }
        public List<WaybillDetail> data{ get; set; }
    }

    /// <summary>
    /// 获得订单跟踪
    /// </summary>
    public class GetOrderTrackOutput
    {
        /// <summary>
        /// 运单号
        /// </summary>
        public string waybill_no{ get; set; }
        /// <summary>
        /// 快递公司名称
        /// </summary>
        public string express_name{ get; set; }
        /// <summary>
        /// 快递公司简称
        /// </summary>
        public string express_code{ get; set; }
        /// <summary>
        /// 状态信息，ok为有快递信息
        /// </summary>
        public string message{ get; set; }
        /// <summary>
        /// html状态码 详见：http://yige.org/tags/ref_httpmessages.php
        /// </summary>
        public string html_status{ get; set; } 
        /// <summary>
        /// 快递单当前的状态 ：　
        /// 0：在途，即货物处于运输过程中；
        /// 1：揽件，货物已由快递公司揽收并且产生了第一条跟踪信息；
        /// 2：疑难，货物寄送过程出了问题；
        /// 3：签收，收件人已签收；
        /// 4：退签，即货物由于用户拒签、超区等原因退回，而且发件人已经签收；
        /// 5：派件，即快递正在进行同城派件；
        /// 6：退回，货物正处于退回发件人的途中；
        /// </summary>
        public int status{ get; set; }
        /// <summary>
        /// 快递在途时间
        /// </summary>
        public string days{ get; set; }
        /// <summary>
        /// 快递详情
        /// </summary>
        public List<TrackDetail> detail{ get; set; }
        public string telephone { get; internal set; }
    }

    /// <summary>
    /// 跟踪详情
    /// </summary>
    public class TrackDetail
    {
        public string time { get; set; }
        public long timestamp { get; set; }
        public string context { get; set; }
    }

    

}